package com.pethub.controller.web;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class fileUploadValidator implements Validator{
	
	 public boolean supports(Class clazz) {
	  //just validate the FileUpload instances
	  return fileUpload.class.isAssignableFrom(clazz);
	 }
	 
	 public void validate(Object target, Errors errors) {
	  
		 fileUpload file = (fileUpload)target;
	  
		  if(file.getMultipartFile().getSize()==0){
		   errors.rejectValue("file", "uploadForm.selectFile",  
		         "Please select a file!");
		  }
	 }
	 
	}
